<?php
    @header("Content-Type:text/html;charset=utf-8");

    @include_once("conn.php");

    if(!isset($_POST["phone"])){
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入完整参数";
        $json = json_encode($obj);
        exit($json);
    }


    $phone = $_POST["phone"];

     // 查询
     $sql = " select s.gid,s.phone,f.id,f.title,f.bigimg,f.price,f.goodsprice,s.byNum,s.isChecked from `shoppingcar` as s,`filalisttwo` as f where s.gid = f.id and phone = '$phone'";

     // 执行mysql语句
     $result = mysqli_query($conn,$sql);
     // print_r($result);
 
     $obj = array();
     if($result){
 
 
         $list = array();
         // 解析数据  => 赋值给变量 $item  =>  有数据,循环解析  没有数据(null) =>跳出循环
         while($item = mysqli_fetch_assoc($result)){
            //  预处理
            // print_r(substr($item["price"],3)*2);die;
             $item["subtotal"] = round(substr($item["price"],3) * $item["byNum"],2);
             $item["isChecked"] = $item["isChecked"]*1;
             array_push($list,$item);
         }
 
         // print_r($list);
 
         $obj["status"] = true;
         $obj["msg"] = "OK";
         $obj["list"] = $list;
 
     }else{
         $obj["status"] = false;
         $obj["msg"] = "sql语句有误";
         $obj["sql"] = $sql;
     }
 
     echo json_encode($obj);
 


?>